home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / comm / mebbs / war.lha / WAR / WAR.REXX < prev   
OS/2 REXX Batch file  |  1994-05-30  |  9KB  |  327 lines

  1. /* Original By J.L. White */
  2. /* re-written and improved by */
  3. /* Robert Lehman of Southwinds bbs for mebbsnet >1.5x */
  4. /* May 29th 1994, (219) 289-3275 Vfast 28.8 Maxnet International 90:91/0 */
  5. /* Mebbs developers #M3005  */
  6.  
  7. SIGNAL ON ERROR
  8. SIGNAL ON SYNTAX
  9. SIGNAL ON IOERR
  10. SIGNAL ON FAILURE
  11.  
  12. parse arg LineNumber
  13.  
  14. OPTIONS RESULTS
  15.  
  16. DoorName = "War"
  17.  
  18. if( ~show( 'l', "mebbsarexx.library" ) )then do
  19. if( ~addlib( "mebbsarexx.library", 0, -30, 0 ) )then do
  20.       say "Could not open library"
  21.       exit 10
  22.    end
  23. end
  24.  
  25. author = 'Robert Lehman'
  26. version = 'Version 2.0'
  27. call getvar doorname,linenumber, 8
  28. gfx = result
  29. if gfx = 1 then do
  30. CLS = 'H'
  31. HOM = ''
  32. BGD = ''
  33. RED = ''
  34. YLW = ''
  35. GRN = ''
  36. CYN = ''
  37. MAG = ''
  38. BLU = ''
  39. GCN = ''
  40. RES = ''
  41. end
  42. else do
  43. CLS = 'H'
  44. HOM = ''
  45. BGD = ''
  46. RED = ''
  47. YLW = ''
  48. GRN = ''
  49. CYN = ''
  50. MAG = ''
  51. BLU = ''
  52. GCN = ''
  53. RES = ''
  54. end
  55.  
  56. call getvar doorname,linenumber, 1
  57. UserName = result
  58.  
  59.  
  60. call Instructions
  61.  
  62. Main:
  63.     UserScore = 26
  64.     MYScore = 26
  65.     call Intro  
  66.     call Slap
  67. return
  68.  
  69.  
  70. Slap:
  71.    do forever 
  72.     call message doorname,linenumber, '  ',1
  73. Call prompt doorname,linenumber, CYN'Press [RETURN] To Continue Or [Q] To Quit'GRN'...>',2
  74.     YesPlay = upper(result)
  75.     if YesPlay = 'Q' then call Totals
  76.     call checkca
  77.     call message doorname,linenumber, CLS,1
  78.     call Deal
  79.     end
  80. return
  81.  
  82. GetColor:
  83.     ColorSet = RANDOM(1,2,Time('s'))
  84.     if ColorSet = 1 then Color = ''
  85.     else Color = ''
  86. return
  87.  
  88. Card:
  89.     Num = RandBoth
  90.     if RandBoth = 1 then Num = 'A'
  91.     if RandBoth = 11 then Num = 'J'
  92.     if RandBoth = 12 then Num = 'Q'
  93.     if RandBoth = 13 then Num = 'K'
  94.     if RandBoth = 10 then call Print2
  95.     else call Print1
  96. return
  97.  
  98. Print1:
  99.     call message doorname,linenumber, CardPos' 'Color''Num'    ',1 
  100.     call message doorname,linenumber, CardPos' 'Color'  *   'Whos' Card',1
  101.     call message doorname,linenumber, CardPos' 'Color'    'Num'',1 
  102. return
  103.  
  104. Print2:
  105.     call message doorname,linenumber, CardPos' 'Color'10   ',1
  106.     call message doorname,linenumber, CardPos' 'Color'  *   'Whos' Card',1
  107.     call message doorname,linenumber, CardPos' 'Color'   10',1 
  108. return
  109.  
  110. Pick:
  111.     Rand1 = RANDOM(1,13,Time('s'))
  112.     RandBoth = Rand1
  113.     call GetColor
  114.     CardPos = ' '
  115.     Whos = 'Your'
  116.     call Card
  117.     Rand2 = RANDOM(1,13,Time('s'))
  118.     RandBoth = Rand2
  119.     call GetColor
  120.     CardPos = '       '
  121.     Whos = 'MY'
  122.     call message doorname,linenumber, ' ',1
  123.     call Card
  124.     if Rand1 = 1 then Rand1 = 14
  125.     if Rand2 = 1 then Rand2 = 14
  126. return
  127.  
  128. Deal:
  129.     call Pick
  130.     CardNum = 1
  131.     call MoreOrLess
  132.     CardNum = 1
  133.     call HowMany
  134. return
  135.  
  136. HowMany:
  137.     if Rand1 = Rand2 then do
  138.         call message doorname,linenumber, ' ',1
  139.         call message doorname,linenumber, 'Its WAR!!!',1
  140.         do x = 1 to 300
  141.         end
  142.         call PickIt
  143.         call PickIt
  144.         call PickIt
  145.         CardNum = CardNum + 3
  146.         if Rand1 = Rand2 then call HowMany  
  147.         else call MoreOrLess
  148.     end
  149. return
  150.  
  151. PickIt:
  152.         call message doorname,linenumber, CLS,1
  153.         call Pick
  154.         do x = 1 to 100
  155.         end
  156. return
  157.  
  158. MoreOrLess:
  159.     call message doorname,linenumber, ' ',1
  160.     if Rand1 > Rand2 then do
  161.         call message doorname,linenumber, CYN'You Win'GRN'!',1
  162.         UserScore = UserScore + CardNum
  163.         MYScore = MYScore - CardNum
  164.         if MYScore <= 0 | UserScore >= 52 then call Done
  165.         end
  166.  
  167.     if Rand1 < Rand2 then do
  168.         call message doorname,linenumber, CYN'You Lose'GRN'!',1
  169.         UserScore = UserScore - CardNum
  170.         MYScore = MYScore + CardNum
  171.         if UserScore <= 0 | MYScore >= 52 then call Done
  172.         end
  173.     call message doorname,linenumber, ' ',1
  174.     call message doorname,linenumber, CYN'Your Score'GRN':'CYN UserScore  GRN'|'CYN' MY Score'GRN':'CYN MYScore,1
  175. return
  176.  
  177. Done:
  178.     call message doorname,linenumber, 'Thats the game! No more cards left...',1
  179.     if UserScore <= 0 then UserScore = 0
  180.     if MYScore <= 0 then MYScore = 0
  181.     if UserScore >= 52 then UserScore = 52
  182.     if MYScore >= 52 then MYScore = 52
  183.     call Totals
  184. return
  185.  
  186. Totals:
  187.     call message doorname,linenumber, ' ',1
  188.     if UserScore > MYScore then do
  189.         Bonus = UserScore - MYScore
  190.         call message doorname,linenumber, 'You Have 'Bonus % 2' More Cards Than When You Started.',1
  191.         call message doorname,linenumber, ' ',1
  192.         Bonus = Bonus % 4
  193.         if MYScore = 0 then Bonus = 30
  194.         if Bonus = 0 then Bonus = 1
  195.         if Bonus = 1 then call message doorname,linenumber, YLW'You Win ',1
  196.         else call message doorname,linenumber, 'You Win ',1
  197.         end
  198.     if UserScore < MYScore then do
  199.         Bonus = MYScore - UserScore
  200.         call message doorname,linenumber, 'You Have 'Bonus % 2' Cards Less Than When You Started.',1
  201.         Bonus = Bonus % 4
  202.         if UserScore = 0 then Bonus = 15
  203.         if Bonus = 0 then Bonus = 1
  204.         if Bonus = 1 then call message doorname,linenumber, YLW'You Lose ',1
  205.         else call message doorname,linenumber, YLW'You Lose ',1
  206.         Bonus = -Bonus
  207.         end
  208.     call message doorname,linenumber, ' ',1
  209.     call Again
  210.     call Finished
  211. return
  212.  
  213.  
  214. Again:
  215.     call message doorname,linenumber, ' ',1
  216.     Call prompt doorname,linenumber, CYN'Do You Want To Play Again 'GRN'('CYN'Y'GRN'/'CYN'N'GRN')'CYN'?',2
  217.     PlayAgain = upper(result)
  218.     if PlayAgain = 'Y' then call Main
  219.     if PlayAgain = 'N' then call Finished
  220.     call checkca
  221. return
  222.  
  223. Finished:
  224.     call message doorname,linenumber, ' ',1
  225.     call message doorname,linenumber, 'Hope You Enjoyed The Game',1
  226.     signal wrap_up
  227.  
  228. Instructions:
  229.     call message doorname,linenumber, CLS,1 
  230.     call message doorname,linenumber, ' ',1
  231.     Call prompt doorname,linenumber, CYN'     Do You Need Instructions 'GRN'('CYN'Y'GRN'/'CYN'N'GRN')'CYN'? ',2
  232.     answer = upper(result)
  233.     if answer = 'Y' then do
  234.         call checkca
  235.         call message doorname,linenumber, CLS,1
  236.         call message doorname,linenumber, ' The object of WAR is to win all the cards in the deck. You start the game',1
  237.         call message doorname,linenumber, 'with half the deck. You & the computer take turns placing one card down at a',1
  238.         call message doorname,linenumber, 'time. Whoever has the highest card wins both cards. If both of your cards',1
  239.         call message doorname,linenumber, 'have the same value, you go to WAR. This means you take 3 cards and place',1
  240.         call message doorname,linenumber, 'them down, the last card is the one to beat. Whoever wins at War will get 3',1
  241.         call message doorname,linenumber, 'cards plus the original one. If you match again in War, you continue to add',1
  242.         call message doorname,linenumber, '3 cards each time. This can really build up your stack.' ,1
  243.         call message doorname,linenumber, 'Whoever has all 52 cards is the winner!!!' ,1
  244.         call message doorname,linenumber, ' You can quit anytime during the game.',1
  245.         call message doorname,linenumber, 'Well That about does it. Enjoy...',1
  246.         call message doorname,linenumber, ' ',1
  247.         call hotkey doorname,linenumber, 'Press [RETURN] To Continue...'
  248.         call checkca
  249.         end
  250. return
  251.  
  252. Intro:
  253.     call message doorname,linenumber, CLS,1
  254.     call message doorname,linenumber, GRN'@   @  @@  @@@'CYN'       'version,1
  255.     call message doorname,linenumber, YLW'@   @ @  @ @  @ ',1
  256.     call message doorname,linenumber, GRN'@ @ @ @@@@ @@@'CYN'       Written By 'author,1
  257.     call message doorname,linenumber, YLW'@@ @@ @  @ @  @ ',1
  258.     call message doorname,linenumber, GRN'@   @ @  @ @   @'CYN'     ',1
  259.     call Delay
  260.     call message doorname,linenumber, CYN'One Moment While I Shuffle The Deck'GRN'...',1
  261.     call Delay
  262.     call message doorname,linenumber, CYN'OK, Now I Will Deal The Cards Out'GRN'...',1
  263.     call Delay
  264.     call message doorname,linenumber, CYN'We Are Ready To Begin!',1
  265.     call Delay
  266. return
  267.  
  268. Delay:
  269.     call message doorname,linenumber, ' ',1
  270.     do x = 1 to 300
  271.     end
  272. return
  273.  
  274. /* error and exit routines */
  275.  
  276. Wrap_up:
  277. call exit_door DoorName,LineNumber
  278. exit 0
  279.  
  280. CHECKCA:
  281. call cdetect doorname,linenumber
  282. carrier = result
  283. if carrier = 'no carrier!' then do
  284. signal getout
  285. end
  286. return
  287.  
  288.  
  289. IOERR:
  290.  
  291.    call message doorname,linenumber,'',1
  292.    Call message doorname,linenumber, '**ALERT** input output error!',1
  293.    err_line = SIGL ; sev = RC
  294.    Call message doorname,linenumber, 'Line: 'err_line'   Severity: 'sev,1
  295.    call hotkey doorname,linenumber,'Press return...'
  296. call exit_door DoorName,LineNumber
  297. exit 10
  298.  
  299. ERROR:
  300.  
  301.    call message doorname,linenumber,'',1
  302.    Call message doorname,linenumber, '**ALERT** General Error!',1
  303.    err_line = SIGL ; sev = RC
  304.    Call message doorname,linenumber, 'Line: 'err_line'   Severity: 'sev,1
  305.    call hotkey doorname,linenumber,'Press return...'
  306. call exit_door DoorName,LineNumber
  307. exit 10
  308.  
  309. SYNTAX:
  310.  
  311.    Call message doorname,linenumber, '**ALERT** Syntax Error!',1
  312.    err_line = SIGL ; sev = RC
  313.    Call message doorname,linenumber, 'Line: 'err_line'   Severity: 'sev,1
  314.    call hotkey doorname,linenumber,'Press return...'
  315. call exit_door DoorName,LineNumber
  316. exit 10
  317.  
  318.  
  319. FAILURE:
  320.  
  321.    Call message doorname,linenumber, '**ALERT** Failure!',1
  322.    err_line = SIGL ; sev = RC
  323.    Call message doorname,linenumber, 'Line: 'err_line'   Severity: 'sev,1
  324.    call hotkey doorname,linenumber,'Press return...'
  325. call exit_door DoorName,LineNumber
  326. exit 10
  327.